/**
 *	bbx 
 */
define(function(require, exports, module) {
	"use strict";
	//每一个页面都要引入的工具类
	var CommonTools = require('CommonTools_Core');
	
	//页面跳转管理类
	var WindowTools = require('WindowTools_Core');
	var accountService = require('Account_Service');
	
	//每一个页面都要引入的工具类
	// initready 要在所有变量初始化做完毕后
	CommonTools.initReady(initData);
	/**
	 * @description 初始化数据,结合initReady使用
	 * plus情况为plusready
	 * 其它情况为直接初始化
	 */
	function initData() {
		//引入必备文件,下拉刷新依赖于mui与mustache
		CommonTools.importFile([
			'js/libs/mui.min.js'
		], function() {
			console.log("init");
			mui.init({
					statusBarBackground: '#f7f7f7'
			});
			WindowTools.preloadTemplate();
			initLogin();
		});
	}

	function initLogin() {
		//检查 "登录状态/锁屏状态" 结束
		var loginButton = document.getElementById('login'); //登录按钮
		var accountBox = document.getElementById('account');//用户名
		var passwordBox = document.getElementById('password');//密码
		var autoLoginButton = document.getElementById("autoLogin");//自动登录
		var regButton = document.getElementById('reg');//注册
		var forgetButton = document.getElementById('forgetPassword');//忘记密码
		loginButton.addEventListener('tap', function(event) {
			var loginInfo = {
				UserAccount: accountBox.value,
				UserPassword: passwordBox.value,
				UserType: 3
			};
			console.log("login");
			accountService.login(loginInfo,function(res){
//				debugger;
				var style = {};
				WindowTools.openWinWithTemplate(null, "../index.html", null, style);
			});
			
		});

		regButton.addEventListener('tap', function(event) {
			var style = {};
			WindowTools.openWinWithTemplate(null, "./reg.html", null, style);
		}, false);
		forgetButton.addEventListener('tap', function(event) {
			var style = {};
			WindowTools.openWinWithTemplate(null, "./forget_password.html", null, style);
		}, false);
	}
});